#ifndef TCPSERVERFORM_H
#define TCPSERVERFORM_H

#include <QWidget>
#include "InputParameter.h"
#include <QTcpServer>
#include <QTcpSocket>

namespace Ui {
class TcpServerForm;
}

class TcpServerForm : public QWidget
{
    Q_OBJECT

public:
    explicit TcpServerForm(QWidget *parent = nullptr);
    ~TcpServerForm();

    bool IsOpen(){
        if(this->m_server && this->m_server->isListening()){
            return true;
        }
        return false;
    };


public:
    void Send(const stParameter& parameter);

public slots:
    void slot_listen();
    void slot_disconnect();

    void slot_newconnection();
    void slot_readyRead();

signals:
    void SigData(const QByteArray& data);
    void SigExtra(const QString&);

private:
    Ui::TcpServerForm *ui;

    QTcpServer* m_server;
    QTcpSocket* m_socket;
};

#endif // TCPSERVERFORM_H
